#include <stdio.h>
#include <unistd.h>

int main()
{
  const char* filename = "log.txt";
  FILE *fp = fopen(filename,"r");
  if(fp == NULL)
  {
    perror("fopen");
    return 1;
  }
  while(1)
  {
    char buffer[128];
    if(!fgets(buffer,sizeof(buffer),fp))
    {
      break;
    }
    printf("from file: %s\n",buffer);
  }
  //int cnt = 1;
  //while(cnt <= 10)
  //{
  //  const char* s = "Hello World\n";
  //  fputs(s,fp);
  //  cnt++;
  //}

  fclose(fp);
  return 0;
}
